<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  request.setAttribute("now",new Date());
%>

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading">
                <h3 class="panel-title">资产入库登记表</h3>
            </div>

            <div style="margin: 10px">

                <!-- Nav tabs -->
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#bsc-tab-1" data-toggle="tab">资产信息</a></li>
                    <c:if test="${asset.numStatus==1}">
                        <li><a href="#bsc-tab-2" data-toggle="tab">使用明细</a></li>
                        <li><a href="#bsc-tab-3" data-toggle="tab">调拨记录</a></li>
                        <li><a href="#bsc-tab-4" data-toggle="tab">维修记录</a></li>
                        <li><a href="#bsc-tab-5" data-toggle="tab">报废记录</a></li>
                    </c:if>
                </ul>

                <!-- Tabs Content -->
                <div class="tab-content">

                    <div class="tab-pane pad-btm fade in active" id="bsc-tab-1">
                        <!-- BASIC FORM ELEMENTS -->
                        <!--===================================================-->
                        <form id="form_asset_input" class="panel-body form-horizontal form-padding">
                            <input type="hidden" name="keyId" id="keyId" value="${asset.id}" />

                            <div class="form-group">
                                <label class="col-md-2 control-label">资产编号<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="assetNo" name="assetNo" class="form-control" value="${asset.assetNo}" readonly>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">资产名称<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="name" name="name" class="form-control" value="${asset.name}" readonly>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">资产品牌<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="brand" name="brand" class="form-control" value="${asset.brand}" readonly>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">规则型号<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="text" id="model" name="model" class="form-control" value="${asset.model}" readonly>
                                </div>
                            </div>


                            <div class="form-group div-Hidden">
                                <label class="col-md-2 control-label">采购日期<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <div class="input-group date">
                                        <input type="text" class="form-control" id="datPurchase" name="datPurchase" disabled
                                               value=<fmt:formatDate pattern="yyyy-MM-dd" value="${asset.datPurchase}" /> >
                                        <span class="input-group-addon"><i class="ti-calendar"></i></span>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">采购金额<i class="fa fa-asterisk txt-color-red"></i></label>
                                <div class="col-md-6">
                                    <input type="number" id="purchaseMoney" name="purchaseMoney" class="form-control" value="${asset.purchaseMoney}" readonly>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-2 control-label">提交人</label>
                                <div class="col-md-2">
                                    <p class="form-control-static">${asset.creater.name}</p>
                                </div>
                                <label class="col-md-2 control-label">提交日期</label>
                                <div class="col-md-2">
                                    <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${asset.dateApply}" /></p>
                                </div>
                            </div>

                        </form>

                        <!--===================================================-->
                        <!-- END BASIC FORM ELEMENTS -->

                        <div class="panel-footer">
                            <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
                                <i class="fa fa-lg fa-mail-reply"></i> 返回视图
                            </a>
                            <c:if test="${asset.numStatus==0}">
                                <a class="btn btn-warning" key="ajax_asset_edit" href="javascript:void(0);"><i class="fa fa-lg fa-edit"></i> 编辑表单 </a>
                            </c:if>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="bsc-tab-2">
                        <div class="table-responsive">
                            <table id="asset_use_table"></table>
                            <div id="asset_use_page"></div>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="bsc-tab-3">
                        <div class="table-responsive">
                            <table id="asset_flit_table"></table>
                            <div id="asset_flit_page"></div>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="bsc-tab-4">
                        <div class="table-responsive">
                            <table id="asset_maintain_table"></table>
                            <div id="asset_maintain_page"></div>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="bsc-tab-5">
                        <div class="table-responsive">
                            <table id="asset_scrap_table"></table>
                            <div id="asset_scrap_page"></div>
                        </div>
                    </div>

                </div>
            </div>

        </div>
    </div>
</div>

<script>
    //返回视图
    $("#apply-re-common").click(returnToHashUrl);

    //编辑
    $("a[key='ajax_asset_edit']").unbind("click").bind("click",function(){
        loadURL("<%=path%>/activiti/asset/edit/"+$("#keyId").val(),$('#page-content'));
    });

    // 加载完成后执行
    $(function(){

        init_grid_asset_use();

        init_grid_asset_flit();

        init_grid_asset_maintain();

        init_grid_asset_scrap();

    })

    function init_grid_asset_use() {
        __init_jqgrid('asset_use_table', 'asset_use_page',
            '<%=path%>/activiti/assetuse/list?assetId='+$("#form_asset_input #keyId").val(),
            ['年', '月', '资产编号','资产名称','使用人', '使用部门','登记日期', '文档状态', 'id'],
            [
                {name: 'year', index: 'year', width: 40, sortable: true, search: false},
                {name: 'month', index: 'month', width: 30, sortable: true, search: false},
                {name: 'assetNo', index: 'assetNo', width: 80, sortable: false, search: false},
                {name: 'name', index: 'name', width: 80, sortable: true, search: false},
                {name: 'user', index: 'user', width: 40, sortable: false, search: false},
                {name: 'useDepartment', index: 'useDepartment', width: 80, sortable: false, search: false},
                {name: 'dateApply', index: 'dateApply', width: 40, sortable: false, search: false},
                {name: 'txtStatus', index: 'txtStatus', width: 40, sortable: false, search: false, formatter: statusFormatUse},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
                autowidth: false,
                width: 1400,
                height: 500,
                postData: {catalog: 0x03}
            }
        );
    }

    function statusFormatUse(cellvalue, options, rowObject){
        if (cellvalue == "已领用") {
            return "本人领用";
        } else if (cellvalue == "已调拨") {
            return "调拨使用";
        } else {
            return cellvalue;
        }
    }

    function init_grid_asset_flit() {
        __init_jqgrid('asset_flit_table', 'asset_flit_page',
            '<%=path%>/activiti/assetflit/list?assetId='+$("#form_asset_input #keyId").val(),
            ['年', '月', '资产编号','资产名称','原使用人', '现使用人','调拨日期', '调拨状态', 'id'],
            [
                {name: 'year', index: 'year', width: 40, sortable: true, search: false},
                {name: 'month', index: 'month', width: 30, sortable: true, search: false},
                {name: 'assetNo', index: 'assetNo', width: 80, sortable: false, search: false},
                {name: 'name', index: 'name', width: 80, sortable: true, search: false},
                {name: 'oldUserName', index: 'oldUserName', width: 40, sortable: false, search: false},
                {name: 'user', index: 'user', width: 40, sortable: false, search: false},
                {name: 'dateApply', index: 'dateApply', width: 40, sortable: false, search: false},
                {name: 'txtStatus', index: 'txtStatus', width: 40, sortable: false, search: false},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
                autowidth: false,
                width: 1400,
                height: 500,
                postData: {catalog: 0x02}
            }
        )
    }

    //年    月     资产编号    资产名称     维修原因    维修结果    维修费用（元）   维修日期
    function init_grid_asset_maintain() {
        __init_jqgrid('asset_maintain_table', 'asset_maintain_page',
            '<%=path%>/activiti/assetmaintain/list?assetId='+$("#form_asset_input #keyId").val(),
            ['年', '月', '资产编号','资产名称','维修原因', '维修结果','维修费用（元）','维修日期', 'id'],
            [
                {name: 'year', index: 'year', width: 40, sortable: true, search: false},
                {name: 'month', index: 'month', width: 30, sortable: true, search: false},
                {name: 'assetNo', index: 'assetNo', width: 80, sortable: false, search: false},
                {name: 'name', index: 'name', width: 80, sortable: true, search: false},
                {name: 'maintainReason', index: 'maintainReason', width: 100, sortable: false, search: false},
                {name: 'maintainResult', index: 'maintainResult', width: 40, sortable: false, search: false},
                {name: 'maintainMoney', index: 'maintainMoney', width: 40, sortable: false, search: false},
                {name: 'dateApply', index: 'dateApply', width: 40, sortable: false, search: false},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
                autowidth: false,
                width: 1400,
                height: 500,
                postData: {catalog: 0x02}
            }
        )
    }

    //年    月    固定资产编号   资产名称       规格型号      金额（元）  报废原因   文档状态
    function init_grid_asset_scrap() {
        __init_jqgrid('asset_scrap_table', 'asset_scrap_page',
            '<%=path%>/activiti/assetscrap/list?assetId='+$("#form_asset_input #keyId").val(),
            ['年', '月', '资产编号','资产名称','规格型号', '金额（元）','报废原因','文档状态', 'id'],
            [
                {name: 'year', index: 'year', width: 40, sortable: true, search: false},
                {name: 'month', index: 'month', width: 30, sortable: true, search: false},
                {name: 'assetNo', index: 'assetNo', width: 80, sortable: false, search: false},
                {name: 'name', index: 'name', width: 80, sortable: true, search: false},
                {name: 'model', index: 'model', width: 60, sortable: false, search: false},
                {name: 'purchaseMoney', index: 'purchaseMoney', width: 40, sortable: false, search: false},
                {name: 'scrapReason', index: 'scrapReason', width: 40, sortable: false, search: false},
                {name: 'txtStatus', index: 'txtStatus', width: 40, sortable: false, search: false},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
                autowidth: false,
                width: 1400,
                height: 500,
                postData: {catalog: 0x02}
            }
        )
    }
</script>
